@extends('layouts.admin-iframe-base')


@section('css')
    <link rel="stylesheet" type="text/css" href="/simditor/simditor.css"/>
@stop

@section('content')
        <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            用户管理
            <small>编辑用户</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li class="active">首页</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">

        <!-- Your Page Content Here -->
        <div class="row">
            <div class="col-md-6 col-xs-12">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">编辑用户</h3>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form class="form-horizontal" id="J-form" action="/admin/user/edit-user" method="post">
                        <input type="hidden" name="id" value="{{$user->id}}">
                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">用户名</label>

                                <div class="col-sm-10">
                                    <input name="name" type="text" value="{{$user->name}}" class="form-control" placeholder="用户名">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">新密码</label>

                                <div class="col-sm-10">
                                    <input name="new_password" type="password" class="form-control" placeholder="不填写新密码不会修改密码">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">邮箱</label>

                                <div class="col-sm-10">
                                    <input name="email" type="email" value="{{$user->email}}" class="form-control" placeholder="Email">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">手机</label>

                                <div class="col-sm-10">
                                    <input name="phone" type="number" value="{{$user->phone}}" class="form-control" placeholder="手机">
                                </div>
                            </div>

                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <button type="submit" class="btn btn-info pull-right">保存</button>
                        </div>
                        <!-- /.box-footer -->
                    </form>
                </div>
            </div>
        </div>

    </section>
    <!-- /.content -->



@stop

@section('js')
    <script>

        $('#J-form').ajaxForm({
            beforeSubmit: function () {
                validator_info_clear($('#J-form'));
            },
            success: function (data) {
                if (data.status == 1) {
                    alert('保存成功！');
                    window.location.href = '/admin/user/index';
                } else {
                    alert(data.error_msg);
                }
            },
            error: function (xhr) {
                validator_info_show($('#J-form'), xhr);
            }
        });



    </script>
@stop